package c.h.a.m0;

import android.app.Activity;
import android.app.UiModeManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build.VERSION;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Display;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.Toast;
import b.i.b.f;
import c.b.a.a.a;
import com.google.android.gms.dynamite.descriptors.com.google.android.gms.measurement.dynamite.ModuleDescriptor;
import com.huawei.hms.adapter.internal.AvailableCode;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import com.huawei.hms.api.ConnectionResult;
import com.huawei.hms.support.api.entity.common.CommonConstant.ACTION;
import com.liuzh.deviceinfo.DeviceInfoApp;
import java.net.URISyntaxException;
import java.util.Locale;

/* compiled from: DeviceAppUtils */
public class h {
    public static final boolean a;
    public static final boolean b;
    public static final boolean c;
    public static final boolean d;

    static {
        int i = VERSION.SDK_INT;
        boolean z = true;
        a = i >= 28;
        b = i >= 29;
        c = i >= 26;
        if (i < 24) {
            z = false;
        }
        d = z;
    }

    public static String a(int i) {
        i--;
        String[] stringArray = DeviceInfoApp.c.getResources().getStringArray(2130903042);
        if (i < 0 || i >= stringArray.length) {
            return DeviceInfoApp.c.getString(2131690514);
        }
        return stringArray[i];
    }

    public static int b(int i) {
        switch (i) {
            case 3:
                return 2131231095;
            case 4:
                return 2131231096;
            case 5:
            case 6:
            case 7:
                return 2131231097;
            case 8:
                return 2131231098;
            case 9:
            case 10:
                return 2131231099;
            case 11:
            case 12:
            case 13:
                return 2131231100;
            case 14:
            case 15:
                return 2131231101;
            case 16:
            case 17:
            case 18:
                return 2131231102;
            case ConnectionResult.SERVICE_MISSING_PERMISSION /*19*/:
            case ModuleDescriptor.MODULE_VERSION /*20*/:
                return 2131231103;
            case 21:
            case 22:
                return 2131231105;
            case 23:
                return 2131231106;
            case 24:
            case 25:
                return 2131231107;
            case 26:
            case AvailableCode.USER_IGNORE_PREVIOUS_POPUP /*27*/:
                return 2131231108;
            case 28:
                return 2131231109;
            case 29:
                return 2131231110;
            case 30:
                return 2131231111;
            default:
                return 2131231104;
        }
    }

    public static CharSequence c(int i) {
        i--;
        String[] stringArray = DeviceInfoApp.c.getResources().getStringArray(2130903041);
        if (i < 0 || i >= stringArray.length) {
            return DeviceInfoApp.c.getString(2131690514);
        }
        String str = stringArray[i];
        stringArray = str.split(" ");
        String str2 = stringArray[stringArray.length - 1];
        if (!str2.equalsIgnoreCase("mr1") && !str2.equalsIgnoreCase("mr2")) {
            return str;
        }
        SpannableString spannableString = new SpannableString(str);
        spannableString.setSpan(new RelativeSizeSpan(0.7f), str.indexOf(str2), str.length(), 0);
        return spannableString;
    }

    public static String d(boolean z) {
        return DeviceInfoApp.c.getString(z ? 2131690575 : 2131690129);
    }

    public static String e(String str) {
        return TextUtils.isEmpty(str) ? "N/A" : str;
    }

    public static void f(Context context, String str, String str2) {
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService("clipboard");
        if (clipboardManager != null) {
            clipboardManager.setPrimaryClip(ClipData.newPlainText(str, str2));
            Toast.makeText(context, 2131689763, 0).show();
        }
    }

    public static void g(Activity activity) {
        if (!q(activity)) {
            activity.getWindow().getDecorView().setSystemUiVisibility(5894);
            h(activity);
        }
    }

    public static void h(Activity activity) {
        LayoutParams attributes = activity.getWindow().getAttributes();
        if (VERSION.SDK_INT >= 28) {
            attributes.layoutInDisplayCutoutMode = 1;
        }
        activity.getWindow().setAttributes(attributes);
    }

    public static String i() {
        float f = Resources.getSystem().getDisplayMetrics().density;
        if (f >= 4.0f) {
            return "xxxhdpi";
        }
        if (f >= 3.0f) {
            return "xxhdpi";
        }
        if (f >= 2.0f) {
            return "xhdpi";
        }
        if (((double) f) >= 1.5d) {
            return "hdpi";
        }
        return f >= 1.0f ? "mdpi" : "ldpi";
    }

    public static String j(int i, int i2) {
        String str = i != 0 ? i != 1 ? i != 2 ? i != 3 ? "" : "signatureOrSystem" : "signature" : "dangerous" : "normal";
        if (o(16, i2)) {
            str = a.D(str, " | privileged(system)");
        }
        if (o(32, i2)) {
            str = a.D(str, " | development");
        }
        if (o(64, i2)) {
            str = a.D(str, " | appop");
        }
        if (o(AesLen.ROOTKEY_COMPONET_LEN, i2)) {
            str = a.D(str, " | pre23");
        }
        if (o(256, i2)) {
            str = a.D(str, " | installer");
        }
        if (o(512, i2)) {
            str = a.D(str, " | verifier");
        }
        if (o(1024, i2)) {
            str = a.D(str, " | preinstalled");
        }
        if (o(2048, i2)) {
            str = a.D(str, " | setup");
        }
        if (o(4096, i2)) {
            str = a.D(str, " | instant");
        }
        if (o(8192, i2)) {
            str = a.D(str, " | runtimeOnly");
        }
        if (o(16384, i2)) {
            str = a.D(str, " | oem");
        }
        if (o(32768, i2)) {
            str = a.D(str, " | vendorPrivileged");
        }
        if (o(65536, i2)) {
            str = a.D(str, " | systemTextClassifier");
        }
        if (o(131072, i2)) {
            str = a.D(str, " | wellbeing");
        }
        if (o(262144, i2)) {
            str = a.D(str, " | documenter");
        }
        if (o(524288, i2)) {
            str = a.D(str, " | configurator");
        }
        if (o(1048576, i2)) {
            str = a.D(str, " | incidentReportApprover");
        }
        return o(2097152, i2) ? a.D(str, " | appPredictor") : str;
    }

    public static Point k() {
        Point point = new Point();
        WindowManager windowManager = (WindowManager) DeviceInfoApp.c.getSystemService("window");
        if (windowManager != null) {
            windowManager.getDefaultDisplay().getRealSize(point);
        }
        return point;
    }

    public static float l() {
        Point point = new Point();
        WindowManager windowManager = (WindowManager) DeviceInfoApp.c.getSystemService("window");
        if (windowManager == null) {
            return 0.0f;
        }
        Display defaultDisplay = windowManager.getDefaultDisplay();
        defaultDisplay.getRealSize(point);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        defaultDisplay.getRealMetrics(displayMetrics);
        float f = ((float) point.x) / displayMetrics.xdpi;
        float f2 = ((float) point.y) / displayMetrics.ydpi;
        return (float) Math.sqrt(Math.pow((double) f2, 2.0d) + Math.pow((double) f, 2.0d));
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:6:0x0044 */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:11:?, code skipped:
            return;
     */
    public static void m(android.content.Context r4, java.lang.String r5) {
        /*
        r0 = "&referrer=";
        r0 = c.b.a.a.a.g(r0);
        r1 = "";
        r2 = android.text.TextUtils.isEmpty(r1);
        if (r2 == 0) goto L_0x0010;
    L_0x000e:
        r1 = "com.liuzh.deviceinfo";
    L_0x0010:
        r0.append(r1);
        r0 = r0.toString();
        r1 = new android.content.Intent;
        r2 = "android.intent.action.VIEW";
        r1.<init>(r2);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r3 = "market://details?id=";
        r2.append(r3);
        r2.append(r5);
        r2.append(r0);
        r2 = r2.toString();
        r2 = android.net.Uri.parse(r2);
        r1 = r1.setData(r2);
        r2 = 268435456; // 0x10000000 float:2.5243549E-29 double:1.32624737E-315;
        r1 = r1.addFlags(r2);
        r4.startActivity(r1);	 Catch:{ ActivityNotFoundException -> 0x0044 }
        goto L_0x006f;
    L_0x0044:
        r2 = new java.lang.StringBuilder;	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r2.<init>();	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r3 = "https://play.google.com/store/apps/details?id=";
        r2.append(r3);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r2.append(r5);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r2.append(r0);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r5 = r2.toString();	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r5 = android.net.Uri.parse(r5);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r5 = r1.setData(r5);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        r4.startActivity(r5);	 Catch:{ ActivityNotFoundException -> 0x0064 }
        goto L_0x006f;
    L_0x0064:
        r5 = 2131689507; // 0x7f0f0023 float:1.9008031E38 double:1.053194553E-314;
        r0 = 0;
        r4 = android.widget.Toast.makeText(r4, r5, r0);
        r4.show();
    L_0x006f:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.h.m(android.content.Context, java.lang.String):void");
    }

    public static void n(Context context, String str) {
        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
        intent.addCategory("android.intent.category.DEFAULT");
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("package:");
        stringBuilder.append(str);
        intent.setData(Uri.parse(stringBuilder.toString()));
        intent.addFlags(268435456);
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException | SecurityException unused) {
            Toast.makeText(context, 2131689507, 0).show();
        } catch (RuntimeException unused2) {
        }
    }

    public static boolean o(int i, int i2) {
        return (i & i2) != 0;
    }

    public static boolean p() {
        UiModeManager uiModeManager = (UiModeManager) DeviceInfoApp.c.getSystemService("uimode");
        boolean z = false;
        if (uiModeManager == null) {
            return false;
        }
        if (uiModeManager.getCurrentModeType() == 4) {
            z = true;
        }
        return z;
    }

    public static boolean q(Activity activity) {
        return activity == null || activity.isFinishing() || activity.isDestroyed();
    }

    public static boolean r() {
        return "CN".equalsIgnoreCase(Locale.getDefault().getCountry());
    }

    public static void s(Context context) {
        Intent intent = new Intent(ACTION.HWID_SCHEME_URL);
        intent.setData(Uri.parse(g.b));
        intent.setFlags(268435456);
        try {
            context.startActivity(intent);
        } catch (Exception unused) {
            Toast.makeText(context, 2131689507, 0).show();
        }
    }

    public static int t(float f, DisplayMetrics displayMetrics) {
        return Math.round(TypedValue.applyDimension(1, f, displayMetrics));
    }

    public static int u(float f, DisplayMetrics displayMetrics) {
        return Math.round(TypedValue.applyDimension(2, f, displayMetrics));
    }

    public static boolean v(Context context) {
        try {
            context.startActivity(Intent.parseUri("alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx03784knocah5pwicbj84", 1));
            return true;
        } catch (ActivityNotFoundException unused) {
            Toast.makeText(context, 2131689507, 0).show();
            return false;
        } catch (SecurityException | URISyntaxException unused2) {
            Toast.makeText(context, 2131690394, 0).show();
            return false;
        }
    }

    public static Drawable w(Drawable drawable, int i) {
        drawable = f.k1(drawable.mutate());
        drawable.setTint(i);
        return drawable;
    }

    public static void x(Context context, String str) {
        Intent intent = new Intent("android.intent.action.DELETE");
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("package:");
        stringBuilder.append(str);
        intent.setData(Uri.parse(stringBuilder.toString()));
        intent.addFlags(268435456);
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            Toast.makeText(context, 2131689507, 0).show();
        } catch (SecurityException unused2) {
            Toast.makeText(context, 2131690181, 0).show();
        }
    }

    public static void y(Class<? extends AppWidgetProvider> cls) {
        DeviceInfoApp deviceInfoApp = DeviceInfoApp.c;
        try {
            int[] appWidgetIds = AppWidgetManager.getInstance(deviceInfoApp).getAppWidgetIds(new ComponentName(deviceInfoApp, cls));
            Intent intent = new Intent(deviceInfoApp, cls);
            intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
            intent.putExtra("appWidgetIds", appWidgetIds);
            deviceInfoApp.sendBroadcast(intent);
        } catch (RuntimeException unused) {
        }
    }
}
